#include "bsp_timer.h"


crm_clocks_freq_type crm_clocks_freq_struct = {0};


void BASE_TIM_Init(void)
{
	crm_clocks_freq_get(&crm_clocks_freq_struct);
	
	crm_periph_clock_enable(BASE_TIM_CRM_CLK, TRUE);
	
	tmr_base_init(BASE_TIM, 9999, (crm_clocks_freq_struct.ahb_freq / 10000) - 1);
	
	tmr_cnt_dir_set(BASE_TIM, TMR_COUNT_UP);
	
	tmr_interrupt_enable(BASE_TIM, TMR_OVF_INT, TRUE);
	
	nvic_irq_enable(BASE_TIM_IRQ, 1, 0);
	
	tmr_counter_enable(BASE_TIM, TRUE);
}